<template>
  <div class="order-page">
    <!-- 顶部筛选区 -->
    <div class="filter-section">
      <el-form :model="filterForm" inline>
        <el-form-item label="订单编号">
          <el-input v-model="filterForm.orderNo" placeholder="请输入" />
        </el-form-item>
        <el-form-item label="订单类型">
          <el-select v-model="filterForm.orderType" placeholder="请选择">
            <el-option label="普通订单" value="normal" />
            <el-option label="特殊订单" value="special" />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">查询</el-button>
          <el-button>重置</el-button>
          <el-button
            >展开 <el-icon><ArrowDown /></el-icon
          ></el-button>
        </el-form-item>
      </el-form>
    </div>

    <!-- 标签页 -->
    <el-tabs v-model="activeTab" class="order-tabs">
      <el-tab-pane label="全部订单" name="all">
        <!-- 表格工具栏 -->
        <div class="table-toolbar">
          <div class="left">
            <el-button type="primary">新建</el-button>
            <el-button>导出</el-button>
          </div>
          <div class="right">
            <el-button>
              <el-icon><Refresh /></el-icon>
            </el-button>
            <el-button>
              <el-icon><Setting /></el-icon>
            </el-button>
          </div>
        </div>

        <!-- 表格 -->
        <el-table :data="tableData" style="width: 100%">
          <el-table-column type="selection" width="50" />
          <el-table-column label="订单编号" prop="orderNo" />
          <el-table-column label="订单类型" prop="orderType" />
          <el-table-column label="订单状态" prop="status">
            <template #default="{ row }">
              <el-tag :type="row.status === '已完成' ? 'success' : 'warning'">
                {{ row.status }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column label="创建时间" prop="createTime" />
          <el-table-column label="操作" width="200">
            <template #default>
              <el-button link type="primary">详情</el-button>
              <el-button link type="primary">编辑</el-button>
              <el-button link type="danger">删除</el-button>
            </template>
          </el-table-column>
        </el-table>

        <!-- 分页 -->
        <div class="pagination-container">
          <el-pagination
            v-model:current-page="currentPage"
            v-model:page-size="pageSize"
            :total="total"
            :page-sizes="[10, 20, 30, 50]"
            layout="total, sizes, prev, pager, next, jumper"
          />
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'

// 筛选表单
const filterForm = reactive({
  orderNo: '',
  orderType: ''
})

// 标签页
const activeTab = ref('all')

// 表格数据
const tableData = ref([
  {
    orderNo: '45678920230913',
    orderType: '普通订单',
    status: '已完成',
    createTime: '2023-09-13 12:00:00'
  }
  // ... 更多数据
])

// 分页
const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(100)
</script>

<style lang="scss" scoped>
.order-page {
  padding: 16px;
  background: #fff;
  border-radius: 4px;
}

.filter-section {
  margin-bottom: 16px;
  padding: 24px 16px;
  background: #fff;
  border-radius: 4px;
}

.order-tabs {
  :deep(.el-tabs__header) {
    margin-bottom: 16px;
  }
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;

  .left {
    display: flex;
    gap: 8px;
  }

  .right {
    display: flex;
    gap: 8px;
  }
}

.pagination-container {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
</style>
